home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13406 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Need help reading sockets
  5. Date: Mon, 25 Mar 1996 11:35:46 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <3156CB62.2584@datalytics.com>
  8. References: <4j23rh$bnu@ginger.lei.net>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Daniel Nakamura wrote:
  16. > I have a problem with reading sockets.  I'm currently using the read
  17. > function to read sockets, then put the information into a buffer.  The
  18. > problem is that I can't read the socket until there is a cariage return.
  19. > I'd like to read the socket character by character instead of waiting for
  20. > the charage return.   Does anyone know how to do it?
  21.  
  22. Can't you just query for the number of bytes waiting and read 
  23. only that many?  I think your problem is that you're asking for 
  24. more data than is available, so the read call is blocking.  You 
  25. can have a buffer to read, say 2K, but ask read for only the 
  26. number of waiting bytes up to 2K.  This should eliminate the 
  27. block.
  28.  
  29. -- 
  30. Robert Stewart        | My opinions are usually my own.
  31. Datalytics, Inc.    | stew@datalytics.com
  32.